﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlueCrest.Module.ConfigEditor.ViewModels;
using BlueCrest.Module.ConfigEditor.Views;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;

namespace BlueCrest.Module.ConfigEditor
{
    public class ConfigEditorModule : IModule 
    {

        private readonly IRegionViewRegistry _regionViewRegistry;
        private readonly IUnityContainer _container;

        public ConfigEditorModule(IRegionViewRegistry registry, IUnityContainer container)
        {
            this._regionViewRegistry = registry;
            _container = container;
        }

        public void Initialize()
        {
            
            _regionViewRegistry.RegisterViewWithRegion("MainRegion", () =>
                                                                         {
                                                                             var view = _container.Resolve<IConfigEditorView>();
                                                                             view.DataContext = _container.Resolve<IConfigEditorViewModel>();
                                                                             return view;
                                                                         });

            
        }
    }
}
